<?php
class SubscribeAction extends CommonAction {
	public function index(){
		$this->listmap.=" and site_id=".$this->siteid;
        parent::_list();
		$this->display();
	}
	
	public function edit(){
		$id = $this->_get('id');
		$db = M('Subscribe');
		$info = $db -> where(array('id' => $id)) -> find();
		import ( '@.ORG.Subscribe.'.$info['classname'] );
		$affclass = $info['classname'];
		$aff = new $affclass($this -> siteid);
		$html = $aff -> createform();
		$this->formhtml = $html;
		parent::edit();
	}
	
	public function add(){
		$this->assign('PaymentConfig', C('SubscribeConfig'));
		parent::add();
	}
	 
	public function update(){
		import ( '@.ORG.Subscribe.'.$this->_post('classname') );
		$affclass = $this->_post('classname');
		$aff = new $affclass($this -> siteid);
		
		$aff -> saveform();
		parent::update();
	}
	
	public function insert(){
		$map['classname'] = $this->_post('classname');
		$map['site_id'] = $this->siteid;
		$ret = $this->dao -> where($map) -> find();
		if($ret){
			$this->error('请不要重复添加该接口！');return;
		}
		parent::insert();
	}
}